<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
	</body>
	<script type="text/javascript">
		window.onload=function(){
			//圆
			let r = new circle(2)
			r.showInfo()
			
			function circle(r){
				this.r = r
				PI=3.14
				C=this.r*2*PI
				S=this.r*this.r*PI
	
				this.showInfo = function(){
					document.writeln("周长："+ C +" "+ "面积："+ S )
				}	
			}
			
			//矩形
			let f1 = new juxing(2,2)
			f1.showInfo()
			
			
			function juxing(a,b){
				this.a = a
				this.b = b
				C=2*(a+b)
				S=a*b
				this.showInfo = function(){
					document.writeln("周长："+ C +" "+ "面积："+ S )
				}	
			}
		}
	</script>
</html>
